<?php

class SettingController extends Controller {
    
    public function actionIndex() {
        $this->render("index");
    }
    
    function actionMember() {
        $model = new Member();
        $this->render("Member", array(
            "model" => $model
        ));
    }
    
    function actionMemberDelete($id) {
        Member::model()->deleteByPk($id);
        $this->redirect("index.php?r=Setting/Member");
    }
    
    //Config Table mt_member_group
    function actionMemberGroup() {
        $model = new MemberGroup();
        $this->render("MemberGroup", array(
            "model" => $model
        ));
    }
    function actionMemberGroupForm($id=NULL) {
        $model = new MemberGroup();
        
        // Save
        if (!empty($_POST["MemberGroup"])) {
            if (!empty($_POST["MemberGroup"]["id"])) {
                $id = $_POST["MemberGroup"]["id"];
                $model = MemberGroup::model()->findByPk($id);
            }
            $model->_attributes = $_POST["MemberGroup"];
            
            if ($model->save()) {
                $this->redirect(array("Setting/MemberGroup"));
            }
        }
        
        // Render
        if (!empty($id)) {
            $model = MemberGroup::model()->findByPk($id);
        }
        
        $this->render("MemberGroupForm", array(
            "model" => $model
        ));
    }
    
    function actionMemberGroupDelete($id) {
        MemberGroup::model()->deleteByPk($id);
        $this->redirect("index.php?r=Setting/MemberGroup");
    }
    //End Config Table mt_member_group

}

?>
